<template>
  <div class="goods-item" @click="toGoodsPage(goods.good_id || goods.id)">
    <div class="img">
      <img :src="goods.banner[0].url" alt="" />
    </div>
    <div class="title">{{ goods.name }}</div>
    <div class="infos">
      <div class="price">
        <b>¥ {{ goods.starting_price }}</b>
      </div>
      <div class="sales">
        已销量 <span>{{ goods.sale }}</span>
      </div>
    </div>
    <div class="button">
      <div class="add_car">加入购物车</div>
    </div>
  </div>
</template>

<script>
export default {
  name: "GoodsItem6",
  props: {
    goods: Object,
  },
  created() {
    console.log(this.goods);
  },
};
</script>

<style lang="scss" scoped>
.goods-item {
  width: 260px;
  box-sizing: border-box;
  background: #ffffff;
  border-radius: 2px;
  padding: 19px;
  font-size: 0;
  border: 1px solid #fff;
  &:hover {
    border-color: #d52c1a;
  }
  .img {
    width: 100%;
    height: 0;
    padding-top: 100%;
    position: relative;
    border-radius: 2px;
    img {
      width: 100%;
      height: 100%;
      position: absolute;
      top: 0;
      left: 0;
      border-radius: 2px;
    }
  }
  .title {
    margin: 10px 0;
    font-size: 16px;
    font-weight: 400;
    color: #333333;
    line-height: 22px;
    height: 44px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .infos {
    display: flex;
    justify-content: space-between;
    align-items: center;
    .price {
      padding: 6px 12px 5px;
      b {
        font-size: 18px;
        color: #d52c1a;
        line-height: 25px;
      }
    }
    .sales {
      font-size: 14px;
      color: #999999;
    }
  }
  .button {
    .add_car {
      height: 28px;
      background: #d52c1a;
      border-radius: 5px;
      font-size: 16px;
      color: #ffffff;
      line-height: 22px;
      display: flex;
      justify-content: center;
      align-items: center;
      cursor: pointer;
    }
  }
}
</style>
